#ifndef COREFARMAPI_H
#define COREFARMAPI_H

#include "CoreLibs.h"

////////////////////////////////////////////
///////// Installed Services ///////////////
#define SERVICE_VERSION_LENGTH 6
////////////////////////////////////////////
////////////// MESSAGES ////////////////////
#define MESSAGE_LENGTH 200
////////////////////////////////////////////
////////////// PrivateUsers ////////////////
#define SERVERID_LENGTH 10
////////////////////////////////////////////
/////////Super Users & Private Users////////  
#define USERNAME_LENGTH 16
#define PASS_LENGTH 32
////////////////////////////////////////////
///////////Update Servers & Servers/////////
#define SERVER_ADDR_LENGTH 16
////////////////////////////////////////////
///Supported Services & Installed Services//
#define SERVICE_NAME_LENGTH 16
////////////////////////////////////////////
////////////////////////////////////
///////////Operations/////////////////
#define OPERATION_LENGTH 28

#define FOREGROUND_WHITE 0x000F
#define FLUSH_STDIN(x) {if(x[strlen(x)-1]!='\n'){do fgets(Junk,16,stdin);while(Junk[strlen(Junk)-1]!='\n');}else x[strlen(x)-1]='\0';}
char Junk[16];
//Flush stdin using Junk array

void changeColor(WORD textColor, WORD backColor){
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), textColor | backColor);//Voodoo magic
}//Change output text color

void changeColorRed(){ changeColor(FOREGROUND_RED, FOREGROUND_INTENSITY); }
void changeColorGreen(){ changeColor(FOREGROUND_GREEN, FOREGROUND_INTENSITY ); }
void changeColorDefault(){ changeColor(FOREGROUND_WHITE, 0x0000); }
void printGreen(char *printString){ changeColorGreen(); fprintf(stdout, "%s", printString); changeColorDefault(); }
void printRed(char *printString){ changeColorRed(); fprintf(stdout,"%s", printString); changeColorDefault(); }
void printWhite(char *printString){ changeColorDefault(); fprintf(stdout, "%s", printString); }
void printError(char *errorMessage){ changeColorRed(); fprintf(stderr,"%s\n", errorMessage); changeColorDefault(); }
void inputToContinue(){ fgets(Junk, 16, stdin); FLUSH_STDIN(Junk); }
void assertMem(void *testMem){ if( !testMem ){ printError("\n\nMemory or file error. \nInput any char to exit.\n"); inputToContinue(); exit(1); } }


void welcomeScreen()
{
	fprintf(stdout, "\t__          __  _                          \n");
	fprintf(stdout, "\t\\ \\        / / | |                         \n");
	fprintf(stdout, "\t \\ \\  /\\  / /__| | ___ ___  _ __ ___   ___ \n");
	fprintf(stdout, "\t  \\ \\/  \\/ / _ \\ |/ __/ _ \\| '_ ` _ \\ / _ \\\n");
	fprintf(stdout, "\t   \\  /\\  /  __/ | (_| (_) | | | | | |  __/\n");
	fprintf(stdout, "\t    \\/  \\/ \\___|_|\\___\\___/|_| |_| |_|\\___|\n");
	fprintf(stdout, "\n\n\n");
	/*fprintf(stdout, "Input any char to continue.\n");
	inputToContinue();*/
}

void exitScreen()
{
	fprintf(stdout, "\n547269706c6520446                                             \n");
	fprintf(stdout, "B::::::::::::::::B                                            \n");
	fprintf(stdout, "B::::::BBBBBB:::::B                                           \n");
	fprintf(stdout, "BB:::::B     B:::::B                                          \n");
	fprintf(stdout, "  B::::B     B:::::Byyyyyyy           yyyyyyy   967697473    \n");
	fprintf(stdout, "  B::::B     B:::::B y:::::y         y:::::yee::::::::::::ee  \n");
	fprintf(stdout, "  B::::BBBBBB:::::B   y:::::y       y:::::ye::::::eeeee:::::ee\n");
	fprintf(stdout, "  B::::313030:::BB     y:::::y     y:::::ye::::::e     e:::::e\n");
	fprintf(stdout, "  B::::BBBBBB:::::B     y:::::y   y:::::y e:::::::eeeee::::::e\n");
	fprintf(stdout, "  B::::B     B:::::B     y:::::y y:::::y  e:::::::::::::::::e \n");
	fprintf(stdout, "  B::::B     B:::::B      y:::::y:::::y   e::::::eeeeeeeeeee  \n");
	fprintf(stdout, "  B::::B     B:::::B       y:::::::::y    e:::::::e           \n");
	fprintf(stdout, "BB:::::BBBBBB::::::B        y:::::::y     e::::::::e          \n");
	fprintf(stdout, "B:::::::::::::::::B          y:::::y       e::::::::eeeeeeee  \n");
	fprintf(stdout, "B::::::::::::::::B          y:::::y         ee:::::::::::::e  \n");
	fprintf(stdout, "BBBBBBBBBBBBBBBBB          y:::::y            eeeeeeeeeeeeee  \n");
	fprintf(stdout, "                          y:::::y                             \n");
	fprintf(stdout, "                         y:::::y                              \n");
	fprintf(stdout, "                        y:::::y                               \n");
	fprintf(stdout, "                       y:::::y                                \n");
	fprintf(stdout, "                      yyyyyyy\n");
}

#endif